﻿
// <copyright file="InitializableConfigurationSection.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The initializable configuration section.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Configuration
{
    using System.Configuration;

    using SubhadraSolutions.Sharp.Utils.Contracts;

    /// <summary>
    /// The initializable configuration section.
    /// </summary>
    public abstract class InitializableConfigurationSection : ConfigurationSection, IInitializable
    {
        #region Public Properties

        /// <summary>
        /// Gets a value indicating whether is initialized.
        /// </summary>
        public bool IsInitialized { get; private set; }

        #endregion Public Properties

        #region Public Methods and Operators

        /// <summary>
        /// The initialize.
        /// </summary>
        public void Initialize()
        {
            if (!this.IsInitialized)
            {
                this.initializeProtected();
                this.IsInitialized = true;
            }
        }

        #endregion Public Methods and Operators

        #region Methods

        /// <summary>
        /// The initialize protected.
        /// </summary>
        protected abstract void initializeProtected();

        #endregion Methods
    }
}